<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

session_start();

$xml_config = simplexml_load_file('config.xml');

include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/technical_class/authentification/User.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/technical_class/language/language.php');
include_once ($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/render/render_char.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/render/render_menu.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/class/Character.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/render/render_header_footer.php');



if (!User::is_user_logged()){
    User::store_url_referer();
    header('Location: login.php');
}
else {
    if (!User::is_user_authorize(User::USER_GROUP_ID)){
        header('Location: unauthorized_access.php');
    }
}


if (isset($_GET['id'])){


    if (is_numeric($_GET['id'])){
        $guild = new Guild();
        $guild = Guild::get_guild((int)$_GET['id']);

        $member_array = $guild->get_member_list_full();
    }

    if (isset($guild)){
//        echo '<script language="JavaScript">alert(\'toto\');</script>';
//        echo '<script language="JavaScript">document.getElementById(\'skillBlock\').style.display=\'block\';</script>' ;
//        echo "<script>document.getElementById('alertBlock').style.visibility='hidden';</script>" ;
    }
    else {

//        echo '<script language="JavaScript">alert(\'titi\');</script>';
//        echo '<script language="JavaScript">document.getElementById(\'alertBlock\').style.visibility=\'visible\';</script>' ;
    }
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <script type="text/javascript" src="external_libraries/jquery-ui/js/jquery-1.4.4.min.js"></script>
        <script type="text/javascript" src="external_libraries/jquery-ui/js/jquery-ui-1.8.7.custom.min.js"></script>
	<script type="text/javascript" src="external_libraries/tablesorter/jquery.tablesorter.min.js"></script>

        <script type="text/javascript" src="js/menudialog.js"></script>
        <script type="text/javascript" src="js/tabs.js"></script>
        <script type="text/javascript" src="js/tablesorter.js"></script>
        
        <link rel="shortcut icon" type="images/x-icon" href="img/quest_jeton.png" />

        <style>
            @import url(css/base.css);
            @import url(external_libraries/jquery-ui/css/smoothness/jquery-ui-1.8.6.custom.css);
            @import url(external_libraries/tablesorter/style/style.css);
        </style>
    </head>
    <body>
        <center>
            <?php
                echo render_page_header().'</br>';
            ?>
            <table>
                <tr>
                    <td valign="top"><?php include('menu.php'); ?></td>
                    <td valign="top">
                        <fieldset>
                            <h1 class="title">
                                <?php
                                    echo Language::get_instance()->get_label('lb_member_list');
                                ?>
                            </h1>

                            <ul class="tabs">
                                <li><a href="#tab_fight"><img class="icon" src="img/job_fight_on.png" /> <?php echo Language::get_instance()->get_label('lb_fight'); ?></a></li>
                                <li><a href="#tab_magic"><img class="icon" src="img/job_magic_on.png" /> <?php echo Language::get_instance()->get_label('lb_magic'); ?></a></li>
                                <li><a href="#tab_harvest"><img class="icon" src="img/job_forage_on.png" /> <?php echo Language::get_instance()->get_label('lb_harvest'); ?></a></li>
                                <li><a href="#tab_armor_craft"><img class="icon" src="img/job_craft_on.png" /> <?php echo Language::get_instance()->get_label('lb_armor_craft'); ?></a></li>
                                <li><a href="#tab_other_craft"><img class="icon" src="img/job_craft_on.png" /> <?php echo Language::get_instance()->get_label('lb_other_craft'); ?></a></li>
                                <li><a href="#tab_stats"><img class="icon" src="img/spe_status.png" /> <?php echo Language::get_instance()->get_label('lb_stat'); ?></a></li>
                                <li><a href="#tab_fame"><img class="icon" src="img/quest_jeton.png" /> <?php echo Language::get_instance()->get_label('lb_fame'); ?></a></li>
                                <li><a href="#tab_connect"><img class="icon" src="img/LM_respawn.png" /> <?php echo Language::get_instance()->get_label('lb_connection_info'); ?></a></li>
                            </ul>

                            <div class="tab_container">
                                <div id="tab_fight" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_fight_skill_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_magic" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_magic_skill_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_harvest" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_harvest_skill_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_armor_craft" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_armor_craft_skill_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_other_craft" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_other_craft_skill_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_stats" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_statistics_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_fame" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_fame_table($member_array);
                                        }
                                    ?>
                                </div>
                                <div id="tab_connect" class="tab_content">
                                    <?php
                                        if (isset($member_array)){
                                            echo generate_member_connection_info_table($member_array);
                                        }
                                    ?>
                                </div>
                            </div>
                        </fieldset>
                    </td>
                </tr>
            </table>
            <?php
                echo render_page_footer();
            ?>
        </center
    </body>
</html>
